<?php

class Application_Model_Costumer extends Sgit_Model
{  
    protected $_name = 'costumer';
    protected $_primary = 'id';
    protected $_cache_activa = TRUE;
    
    public function getCostumer($values)
    {
        
        //permite pasar unico parametro id del contador
        if(is_numeric($values)){
            $id=$values;unset($values);$values['id']=$id;unset($id);
        } 
        
        $select=$this->getAdapter()
            ->select()
            ->from(array($this->_name));

        if (is_array($values['id']) || is_numeric($values['id']))
            $select->where("{$this->_name}.id IN (?)", $values['id']);
        
        $rows = $this->getAdapter()->fetchAll($select);
        
        $m_pep=new Application_Model_Pep();
        
        
        $peps= $m_pep->getAll(array('id_costumer IS NOT NULL'),null,null,null,null,null,array('id','id_costumer'));
        $peps=$this->assocArray($peps,'id_costumer','id');

        foreach($rows as &$v)
        {
            $v['pep']=$peps[$v['id']];
        }
        
        if (is_numeric($values['id']))
            return $rows[0];
        else
            return $rows;

    }

    
}  




